#include "Sprite.h"
#include <allegro.h>

Sprite::Sprite(void):
x(0),
y(0),
width(0),
height(0),
dest(NULL),
src(NULL),
rotation(0),
visible(true),
alphaBlended(false)
{
}

Sprite::Sprite(BITMAP *_src, BITMAP *_dest, signed int _x, signed int _y, unsigned int _width, unsigned int _height, bool _alphaBlended):
x(_x),
y(_y),
width(_width),
height(_height),
src(_src),
dest(_dest),
alphaBlended(_alphaBlended),
rotation(0),
visible(true)
{
	//alpha = 250;
}

void Sprite::draw()
{
	if(visible)
	{
		if(rotation)
		{
			rotate_sprite(dest, src, x, y, ftofix(rotation));
		}
		else if(alphaBlended)
		{
			set_alpha_blender();
			draw_trans_sprite(dest, src, x, y);
		}
		else
		{
			draw_sprite(dest, src, x, y);
		}
	}
}

Sprite::~Sprite(void)
{
	if(!Config::LOAD_GRAPHIC && src != NULL )
		release_bitmap(src);
}
